String

class String : Comparable<String> , CharSequence

Types

Companion
Link copied to clipboard
Native
object Companion

Functions

compareTo
Link copied to clipboard
Native
open operator external override fun compareTo(other: String): Int

Compares this object with the specified object for order. Returns zero if this object is equal to the specified other object, a negative number if it's less than other, or a positive number if it's greater than other.

equals
Link copied to clipboard
Native
open operator external override fun equals(other: Any?): Boolean
get
Link copied to clipboard
Native
open operator external override fun get(index: Int): Char

Returns the character of this string at the specified index.

hashCode
Link copied to clipboard
Native
open external override fun hashCode(): Int
plus
Link copied to clipboard
Native
operator fun plus(other: Any?): String
subSequence
Link copied to clipboard
Native
open external override fun subSequence(startIndex: Int, endIndex: Int): CharSequence

Returns a new character sequence that is a subsequence of this character sequence, starting at the specified startIndex and ending right before the specified endIndex.

toString
Link copied to clipboard
Native
open override fun toString(): String

Properties

length
Link copied to clipboard
Native
open override val length: Int

Returns the length of this character sequence.

Extensions

byteInputStream
Link copied to clipboard
inline fun String.byteInputStream(charset: Charset = Charsets.UTF_8): ByteArrayInputStream

Creates a new byte input stream for the string.

capitalize
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.capitalize(locale: Locale): String

Returns a copy of this string having its first letter titlecased using the rules of the specified locale, or the original string if it's empty or already starts with a title case letter.

@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.capitalize(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.capitalize(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.capitalize(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.capitalize(): String

Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter.

codePointAt
Link copied to clipboard
inline fun String.codePointAt(index: Int): Int

Returns the character (Unicode code point) at the specified index.

codePointBefore
Link copied to clipboard
inline fun String.codePointBefore(index: Int): Int

Returns the character (Unicode code point) before the specified index.

codePointCount
Link copied to clipboard
inline fun String.codePointCount(beginIndex: Int, endIndex: Int): Int

Returns the number of Unicode code points in the specified text range of this String.

compareTo
Link copied to clipboard
fun String.compareTo(other: String, ignoreCase: Boolean = false): Int
fun String.compareTo(other: String, ignoreCase: Boolean = false): Int

Compares two strings lexicographically, optionally ignoring case differences.

fun String.compareTo(other: String, ignoreCase: Boolean = false): Int
fun String.compareTo(other: String, ignoreCase: Boolean = false): Int
concat
Link copied to clipboard
JS
inline fun String.concat(str: String): String
contentEquals
Link copied to clipboard
inline fun String.contentEquals(charSequence: CharSequence): Boolean

Returns true if this string is equal to the contents of the specified CharSequence, false otherwise.

inline fun String.contentEquals(stringBuilder: StringBuffer): Boolean

Returns true if this string is equal to the contents of the specified StringBuffer, false otherwise.

cstr
Link copied to clipboard
Native
val String.cstr: CValues<ByteVar>
decapitalize
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.decapitalize(locale: Locale): String

Returns a copy of this string having its first letter lowercased using the rules of the specified locale, or the original string, if it's empty or already starts with a lower case letter.

@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.decapitalize(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.decapitalize(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.decapitalize(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.decapitalize(): String

Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.

drop
Link copied to clipboard
Common
fun String.drop(n: Int): String

Returns a string with the first n characters removed.

dropLast
Link copied to clipboard
Common
fun String.dropLast(n: Int): String

Returns a string with the last n characters removed.

dropLastWhile
Link copied to clipboard
Common
inline fun String.dropLastWhile(predicate: (Char) -> Boolean): String

Returns a string containing all characters except last characters that satisfy the given predicate.

dropWhile
Link copied to clipboard
Common
inline fun String.dropWhile(predicate: (Char) -> Boolean): String

Returns a string containing all characters except first characters that satisfy the given predicate.

encodeToByteArray
Link copied to clipboard
fun String.encodeToByteArray(): ByteArray
fun String.encodeToByteArray(): ByteArray
fun String.encodeToByteArray(): ByteArray
fun String.encodeToByteArray(): ByteArray

Encodes this string to an array of bytes in UTF-8 encoding.

fun String.encodeToByteArray(startIndex: Int = 0, endIndex: Int = this.length, throwOnInvalidSequence: Boolean = false): ByteArray
fun String.encodeToByteArray(startIndex: Int = 0, endIndex: Int = this.length, throwOnInvalidSequence: Boolean = false): ByteArray
fun String.encodeToByteArray(startIndex: Int = 0, endIndex: Int = this.length, throwOnInvalidSequence: Boolean = false): ByteArray
fun String.encodeToByteArray(startIndex: Int = 0, endIndex: Int = this.length, throwOnInvalidSequence: Boolean = false): ByteArray

Encodes this string or its substring to an array of bytes in UTF-8 encoding.

endsWith
Link copied to clipboard
Common
fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean
fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean
fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean
fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean

Returns true if this string ends with the specified suffix.

equals
Link copied to clipboard
fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean
fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean
fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean

Returns true if this string is equal to other, optionally ignoring character case.

JS
fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean
filter
Link copied to clipboard
Common
inline fun String.filter(predicate: (Char) -> Boolean): String

Returns a string containing only those characters from the original string that match the given predicate.

filterIndexed
Link copied to clipboard
Common
inline fun String.filterIndexed(predicate: (index: Int, Char) -> Boolean): String

Returns a string containing only those characters from the original string that match the given predicate.

filterNot
Link copied to clipboard
Common
inline fun String.filterNot(predicate: (Char) -> Boolean): String

Returns a string containing only those characters from the original string that do not match the given predicate.

format
Link copied to clipboard
inline fun String.format(vararg args: Any?): String

Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the default locale.

@DeprecatedSinceKotlin(hiddenSince = "1.4")
inline fun String.format(locale: Locale, vararg args: Any?): String

Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale.

@JvmName(name = "formatNullable")
inline fun String.format(locale: Locale?, vararg args: Any?): String

Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale. If locale is null then no localization is applied.

intern
Link copied to clipboard
inline fun String.intern(): String

Returns a canonical representation for this string object.

lowercase
Link copied to clipboard
inline fun String.lowercase(locale: Locale): String

Returns a copy of this string converted to lower case using the rules of the specified locale.

fun String.lowercase(): String
inline fun String.lowercase(): String
inline fun String.lowercase(): String
fun String.lowercase(): String

Returns a copy of this string converted to lower case using Unicode mapping rules of the invariant locale.

match
Link copied to clipboard
JS
inline fun String.match(regex: String): Array<String>?
matches
Link copied to clipboard
JS
fun String.matches(regex: String): Boolean
offsetByCodePoints
Link copied to clipboard
inline fun String.offsetByCodePoints(index: Int, codePointOffset: Int): Int

Returns the index within this string that is offset from the given index by codePointOffset code points.

orEmpty
Link copied to clipboard
Common
inline fun String?.orEmpty(): String

Returns the string if it is not null, or the empty string otherwise.

padEnd
Link copied to clipboard
Common
fun String.padEnd(length: Int, padChar: Char = ' '): String

Pads the string to the specified length at the end with the specified character or space.

padStart
Link copied to clipboard
Common
fun String.padStart(length: Int, padChar: Char = ' '): String

Pads the string to the specified length at the beginning with the specified character or space.

partition
Link copied to clipboard
Common
inline fun String.partition(predicate: (Char) -> Boolean): Pair<String, String>

Splits the original string into pair of strings, where first string contains characters for which predicate yielded true, while second string contains characters for which predicate yielded false.

plus
Link copied to clipboard
Common
operator fun String?.plus(other: Any?): String

Concatenates this string with the string representation of the given other object. If either the receiver or the other object are null, they are represented as the string "null".

operator fun String?.plus(other: Any?): String

Concatenates this string with the string representation of the given other object. If either the receiver or the other object are null, they are represented as the string "null".

Native
inline operator fun String?.plus(other: Any?): String
prependIndent
Link copied to clipboard
Common
fun String.prependIndent(indent: String = " "): String

Prepends indent to every line of the original string.

reader
Link copied to clipboard
inline fun String.reader(): StringReader

Creates a new reader for the string.

refTo
Link copied to clipboard
Native
fun String.refTo(index: Int): CValuesRef<COpaque>
regionMatches
Link copied to clipboard
fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean
fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean

Returns true if the specified range in this string is equal to the specified range in another string.

removePrefix
Link copied to clipboard
Common
fun String.removePrefix(prefix: CharSequence): String

If this string starts with the given prefix, returns a copy of this string with the prefix removed. Otherwise, returns this string.

removeRange
Link copied to clipboard
Common
inline fun String.removeRange(startIndex: Int, endIndex: Int): String

Removes the part of a string at a given range.

inline fun String.removeRange(range: IntRange): String

Removes the part of a string at the given range.

removeSuffix
Link copied to clipboard
Common
fun String.removeSuffix(suffix: CharSequence): String

If this string ends with the given suffix, returns a copy of this string with the suffix removed. Otherwise, returns this string.

removeSurrounding
Link copied to clipboard
Common
fun String.removeSurrounding(prefix: CharSequence, suffix: CharSequence): String

Removes from a string both the given prefix and suffix if and only if it starts with the prefix and ends with the suffix. Otherwise returns this string unchanged.

fun String.removeSurrounding(delimiter: CharSequence): String

Removes the given delimiter string from both the start and the end of this string if and only if it starts with and ends with the delimiter. Otherwise returns this string unchanged.

replace
Link copied to clipboard
fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String
fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String
fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String
fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String

Returns a new string with all occurrences of oldChar replaced with newChar.

fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String
fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String
fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String
fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String

Returns a new string obtained by replacing all occurrences of the oldValue substring in this string with the specified newValue string.

replaceAfter
Link copied to clipboard
Common
fun String.replaceAfter(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String
fun String.replaceAfter(delimiter: String, replacement: String, missingDelimiterValue: String = this): String

Replace part of string after the first occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

replaceAfterLast
Link copied to clipboard
Common
fun String.replaceAfterLast(delimiter: String, replacement: String, missingDelimiterValue: String = this): String
fun String.replaceAfterLast(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String

Replace part of string after the last occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

replaceBefore
Link copied to clipboard
Common
fun String.replaceBefore(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String
fun String.replaceBefore(delimiter: String, replacement: String, missingDelimiterValue: String = this): String

Replace part of string before the first occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

replaceBeforeLast
Link copied to clipboard
Common
fun String.replaceBeforeLast(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String
fun String.replaceBeforeLast(delimiter: String, replacement: String, missingDelimiterValue: String = this): String

Replace part of string before the last occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

replaceFirst
Link copied to clipboard
fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String
fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String
fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String

Returns a new string with the first occurrence of oldChar replaced with newChar.

JS
fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String
fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String
fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String
fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String
fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String

Returns a new string obtained by replacing the first occurrence of the oldValue substring in this string with the specified newValue string.

replaceFirstChar
Link copied to clipboard
Common
@JvmName(name = "replaceFirstCharWithChar")
inline fun String.replaceFirstChar(transform: (Char) -> Char): String
@JvmName(name = "replaceFirstCharWithCharSequence")
inline fun String.replaceFirstChar(transform: (Char) -> CharSequence): String

Returns a copy of this string having its first character replaced with the result of the specified transform, or the original string if it's empty.

replaceIndent
Link copied to clipboard
Common
fun String.replaceIndent(newIndent: String = ""): String

Detects a common minimal indent like it does trimIndent and replaces it with the specified newIndent.

replaceIndentByMargin
Link copied to clipboard
Common
fun String.replaceIndentByMargin(newIndent: String = "", marginPrefix: String = "|"): String

Detects indent by marginPrefix as it does trimMargin and replace it with newIndent.

replaceRange
Link copied to clipboard
Common
inline fun String.replaceRange(startIndex: Int, endIndex: Int, replacement: CharSequence): String

Replaces the part of the string at the given range with the replacement char sequence.

inline fun String.replaceRange(range: IntRange, replacement: CharSequence): String

Replace the part of string at the given range with the replacement string.

reversed
Link copied to clipboard
Common
inline fun String.reversed(): String

Returns a string with characters in reversed order.

slice
Link copied to clipboard
Common
fun String.slice(indices: IntRange): String

Returns a string containing characters of the original string at the specified range of indices.

inline fun String.slice(indices: Iterable<Int>): String

Returns a string containing characters of the original string at specified indices.

startsWith
Link copied to clipboard
Common
fun String.startsWith(prefix: String, ignoreCase: Boolean = false): Boolean
fun String.startsWith(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean
fun String.startsWith(prefix: String, ignoreCase: Boolean = false): Boolean
fun String.startsWith(prefix: String, ignoreCase: Boolean = false): Boolean
fun String.startsWith(prefix: String, ignoreCase: Boolean = false): Boolean

Returns true if this string starts with the specified prefix.

fun String.startsWith(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean
fun String.startsWith(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean
fun String.startsWith(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean

Returns true if a substring of this string starting at the specified offset startIndex starts with the specified prefix.

subSequence
Link copied to clipboard
Common
inline fun String.subSequence(start: Int, end: Int): CharSequence

Returns a subsequence of this char sequence.

substring
Link copied to clipboard
Common
fun String.substring(range: IntRange): String

Returns a substring specified by the given range of indices.

fun String.substring(startIndex: Int): String
fun String.substring(startIndex: Int, endIndex: Int): String
inline fun String.substring(startIndex: Int): String
inline fun String.substring(startIndex: Int, endIndex: Int): String
inline fun String.substring(startIndex: Int): String
inline fun String.substring(startIndex: Int): String

Returns a substring of this string that starts at the specified startIndex and continues to the end of the string.

inline fun String.substring(startIndex: Int, endIndex: Int): String
inline fun String.substring(startIndex: Int, endIndex: Int): String

Returns the substring of this string starting at the startIndex and ending right before the endIndex.

substringAfter
Link copied to clipboard
Common
fun String.substringAfter(delimiter: Char, missingDelimiterValue: String = this): String
fun String.substringAfter(delimiter: String, missingDelimiterValue: String = this): String

Returns a substring after the first occurrence of delimiter. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

substringAfterLast
Link copied to clipboard
Common
fun String.substringAfterLast(delimiter: Char, missingDelimiterValue: String = this): String
fun String.substringAfterLast(delimiter: String, missingDelimiterValue: String = this): String

Returns a substring after the last occurrence of delimiter. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

substringBefore
Link copied to clipboard
Common
fun String.substringBefore(delimiter: Char, missingDelimiterValue: String = this): String
fun String.substringBefore(delimiter: String, missingDelimiterValue: String = this): String

Returns a substring before the first occurrence of delimiter. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

substringBeforeLast
Link copied to clipboard
Common
fun String.substringBeforeLast(delimiter: Char, missingDelimiterValue: String = this): String
fun String.substringBeforeLast(delimiter: String, missingDelimiterValue: String = this): String

Returns a substring before the last occurrence of delimiter. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.

take
Link copied to clipboard
Common
fun String.take(n: Int): String

Returns a string containing the first n characters from this string, or the entire string if this string is shorter.

takeLast
Link copied to clipboard
Common
fun String.takeLast(n: Int): String

Returns a string containing the last n characters from this string, or the entire string if this string is shorter.

takeLastWhile
Link copied to clipboard
Common
inline fun String.takeLastWhile(predicate: (Char) -> Boolean): String

Returns a string containing last characters that satisfy the given predicate.

takeWhile
Link copied to clipboard
Common
inline fun String.takeWhile(predicate: (Char) -> Boolean): String

Returns a string containing the first characters that satisfy the given predicate.

toBigDecimal
Link copied to clipboard
inline fun String.toBigDecimal(): BigDecimal
inline fun String.toBigDecimal(mathContext: MathContext): BigDecimal

Parses the string as a java.math.BigDecimal number and returns the result.

toBigDecimalOrNull
Link copied to clipboard
fun String.toBigDecimalOrNull(): BigDecimal?
fun String.toBigDecimalOrNull(mathContext: MathContext): BigDecimal?

Parses the string as a java.math.BigDecimal number and returns the result or null if the string is not a valid representation of a number.

toBigInteger
Link copied to clipboard
inline fun String.toBigInteger(): BigInteger
inline fun String.toBigInteger(radix: Int): BigInteger

Parses the string as a java.math.BigInteger number and returns the result.

toBigIntegerOrNull
Link copied to clipboard
fun String.toBigIntegerOrNull(): BigInteger?
fun String.toBigIntegerOrNull(radix: Int): BigInteger?

Parses the string as a java.math.BigInteger number and returns the result or null if the string is not a valid representation of a number.

toBoolean
Link copied to clipboard
@DeprecatedSinceKotlin(hiddenSince = "1.4")
fun String.toBoolean(): Boolean
@DeprecatedSinceKotlin(hiddenSince = "1.4")
inline fun String.toBoolean(): Boolean
@DeprecatedSinceKotlin(hiddenSince = "1.4")
inline fun String.toBoolean(): Boolean
@DeprecatedSinceKotlin(hiddenSince = "1.4")
inline fun String.toBoolean(): Boolean

Returns true if the content of this string is equal to the word "true", ignoring case, and false otherwise.

fun String?.toBoolean(): Boolean
@JvmName(name = "toBooleanNullable")
inline fun String?.toBoolean(): Boolean
fun String?.toBoolean(): Boolean
inline fun String?.toBoolean(): Boolean

Returns true if this string is not null and its content is equal to the word "true", ignoring case, and false otherwise.

toBooleanStrict
Link copied to clipboard
Common
fun String.toBooleanStrict(): Boolean

Returns true if the content of this string is equal to the word "true", false if it is equal to "false", and throws an exception otherwise.

toBooleanStrictOrNull
Link copied to clipboard
Common
fun String.toBooleanStrictOrNull(): Boolean?

Returns true if the content of this string is equal to the word "true", false if it is equal to "false", and null otherwise.

toByte
Link copied to clipboard
Common
fun String.toByte(): Byte
fun String.toByte(radix: Int): Byte

Parses the string as a signed Byte number and returns the result.

inline fun String.toByte(): Byte
inline fun String.toByte(radix: Int): Byte

Parses the string as a signed Byte number and returns the result.

JS
fun String.toByte(): Byte
fun String.toByte(radix: Int): Byte

Parses the string as a signed Byte number and returns the result.

Native
inline fun String.toByte(): Byte
inline fun String.toByte(radix: Int): Byte

Parses the string as a signed Byte number and returns the result.

toByteArray
Link copied to clipboard
inline fun String.toByteArray(charset: Charset = Charsets.UTF_8): ByteArray

Encodes the contents of this string using the specified character set and returns the resulting byte array.

toByteOrNull
Link copied to clipboard
Common
fun String.toByteOrNull(): Byte?
fun String.toByteOrNull(radix: Int): Byte?

Parses the string as a signed Byte number and returns the result or null if the string is not a valid representation of a number.

toCharArray
Link copied to clipboard
inline fun String.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = length): CharArray

Copies characters from this string into the destination character array and returns that array.

Common
fun String.toCharArray(): CharArray

Returns a CharArray containing characters of this string.

inline fun String.toCharArray(): CharArray

Returns a CharArray containing characters of this string.

JS
fun String.toCharArray(): CharArray

Returns a CharArray containing characters of this string.

Native
fun String.toCharArray(): CharArray

Returns a CharArray containing characters of this string.

Common
fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray

Returns a CharArray containing characters of this string or its substring.

fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray

Returns a CharArray containing characters of this string or its substring.

JS
fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray

Returns a CharArray containing characters of this string or its substring.

Native
fun String.toCharArray(startIndex: Int = 0, endIndex: Int = this.length): CharArray

Returns a CharArray containing characters of this string or its substring.

toDouble
Link copied to clipboard
Common
fun String.toDouble(): Double

Parses the string as a Double number and returns the result.

inline fun String.toDouble(): Double

Parses the string as a Double number and returns the result.

JS
fun String.toDouble(): Double

Parses the string as a Double number and returns the result.

Native
inline fun String.toDouble(): Double

Parses the string as a Double number and returns the result.

toDoubleOrNull
Link copied to clipboard
Common
fun String.toDoubleOrNull(): Double?

Parses the string as a Double number and returns the result or null if the string is not a valid representation of a number.

fun String.toDoubleOrNull(): Double?

Parses the string as a Double number and returns the result or null if the string is not a valid representation of a number.

JS
fun String.toDoubleOrNull(): Double?

Parses the string as a Double number and returns the result or null if the string is not a valid representation of a number.

Native
fun String.toDoubleOrNull(): Double?

Parses the string as a Double number and returns the result or null if the string is not a valid representation of a number.

toFloat
Link copied to clipboard
Common
fun String.toFloat(): Float

Parses the string as a Float number and returns the result.

inline fun String.toFloat(): Float

Parses the string as a Float number and returns the result.

JS
inline fun String.toFloat(): Float

Parses the string as a Float number and returns the result.

Native
inline fun String.toFloat(): Float

Parses the string as a Float number and returns the result.

toFloatOrNull
Link copied to clipboard
Common
fun String.toFloatOrNull(): Float?

Parses the string as a Float number and returns the result or null if the string is not a valid representation of a number.

fun String.toFloatOrNull(): Float?

Parses the string as a Float number and returns the result or null if the string is not a valid representation of a number.

JS
inline fun String.toFloatOrNull(): Float?

Parses the string as a Float number and returns the result or null if the string is not a valid representation of a number.

Native
fun String.toFloatOrNull(): Float?

Parses the string as a Float number and returns the result or null if the string is not a valid representation of a number.

toInt
Link copied to clipboard
Common
fun String.toInt(): Int
fun String.toInt(radix: Int): Int

Parses the string as an Int number and returns the result.

inline fun String.toInt(): Int
inline fun String.toInt(radix: Int): Int

Parses the string as an Int number and returns the result.

JS
fun String.toInt(): Int
fun String.toInt(radix: Int): Int

Parses the string as an Int number and returns the result.

Native
inline fun String.toInt(): Int
inline fun String.toInt(radix: Int): Int

Parses the string as an Int number and returns the result.

toIntOrNull
Link copied to clipboard
Common
fun String.toIntOrNull(): Int?
fun String.toIntOrNull(radix: Int): Int?

Parses the string as an Int number and returns the result or null if the string is not a valid representation of a number.

toLong
Link copied to clipboard
Common
fun String.toLong(): Long
fun String.toLong(radix: Int): Long

Parses the string as a Long number and returns the result.

inline fun String.toLong(): Long
inline fun String.toLong(radix: Int): Long

Parses the string as a Long number and returns the result.

JS
fun String.toLong(): Long
fun String.toLong(radix: Int): Long

Parses the string as a Long number and returns the result.

Native
inline fun String.toLong(): Long
inline fun String.toLong(radix: Int): Long

Parses the string as a Long number and returns the result.

toLongOrNull
Link copied to clipboard
Common
fun String.toLongOrNull(): Long?
fun String.toLongOrNull(radix: Int): Long?

Parses the string as a Long number and returns the result or null if the string is not a valid representation of a number.

toLowerCase
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.5")
inline fun String.toLowerCase(locale: Locale): String

Returns a copy of this string converted to lower case using the rules of the specified locale.

@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.toLowerCase(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
inline fun String.toLowerCase(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
inline fun String.toLowerCase(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.toLowerCase(): String

Returns a copy of this string converted to lower case using the rules of the default locale.

toPattern
Link copied to clipboard
inline fun String.toPattern(flags: Int = 0): Pattern

Converts the string into a regular expression Pattern optionally with the specified flags from Pattern or'd together so that strings can be split or matched on.

toRegex
Link copied to clipboard
Common
inline fun String.toRegex(): Regex

Converts the string into a regular expression Regex with the default options.

inline fun String.toRegex(option: RegexOption): Regex

Converts the string into a regular expression Regex with the specified single option.

inline fun String.toRegex(options: Set<RegexOption>): Regex

Converts the string into a regular expression Regex with the specified set of options.

toShort
Link copied to clipboard
Common
fun String.toShort(): Short
fun String.toShort(radix: Int): Short

Parses the string as a Short number and returns the result.

inline fun String.toShort(): Short
inline fun String.toShort(radix: Int): Short

Parses the string as a Short number and returns the result.

JS
fun String.toShort(): Short
fun String.toShort(radix: Int): Short

Parses the string as a Short number and returns the result.

Native
inline fun String.toShort(): Short
inline fun String.toShort(radix: Int): Short

Parses the string as a Short number and returns the result.

toShortOrNull
Link copied to clipboard
Common
fun String.toShortOrNull(): Short?
fun String.toShortOrNull(radix: Int): Short?

Parses the string as a Short number and returns the result or null if the string is not a valid representation of a number.

toUByte
Link copied to clipboard
Common
fun String.toUByte(): UByte
fun String.toUByte(radix: Int): UByte

Parses the string as a signed UByte number and returns the result.

toUByteOrNull
Link copied to clipboard
Common
fun String.toUByteOrNull(): UByte?
fun String.toUByteOrNull(radix: Int): UByte?

Parses the string as an UByte number and returns the result or null if the string is not a valid representation of a number.

toUInt
Link copied to clipboard
Common
fun String.toUInt(): UInt
fun String.toUInt(radix: Int): UInt

Parses the string as an UInt number and returns the result.

toUIntOrNull
Link copied to clipboard
Common
fun String.toUIntOrNull(): UInt?
fun String.toUIntOrNull(radix: Int): UInt?

Parses the string as an UInt number and returns the result or null if the string is not a valid representation of a number.

toULong
Link copied to clipboard
Common
fun String.toULong(): ULong
fun String.toULong(radix: Int): ULong

Parses the string as a ULong number and returns the result.

toULongOrNull
Link copied to clipboard
Common
fun String.toULongOrNull(): ULong?
fun String.toULongOrNull(radix: Int): ULong?

Parses the string as an ULong number and returns the result or null if the string is not a valid representation of a number.

toUpperCase
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.5")
inline fun String.toUpperCase(locale: Locale): String

Returns a copy of this string converted to upper case using the rules of the specified locale.

@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.toUpperCase(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
inline fun String.toUpperCase(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
inline fun String.toUpperCase(): String
@DeprecatedSinceKotlin(warningSince = "1.5")
fun String.toUpperCase(): String

Returns a copy of this string converted to upper case using the rules of the default locale.

toUShort
Link copied to clipboard
Common
fun String.toUShort(): UShort
fun String.toUShort(radix: Int): UShort

Parses the string as a UShort number and returns the result.

toUShortOrNull
Link copied to clipboard
Common
fun String.toUShortOrNull(): UShort?
fun String.toUShortOrNull(radix: Int): UShort?

Parses the string as an UShort number and returns the result or null if the string is not a valid representation of a number.

trim
Link copied to clipboard
Common
inline fun String.trim(predicate: (Char) -> Boolean): String

Returns a string having leading and trailing characters matching the predicate removed.

fun String.trim(vararg chars: Char): String

Returns a string having leading and trailing characters from the chars array removed.

inline fun String.trim(): String

Returns a string having leading and trailing whitespace removed.

trimEnd
Link copied to clipboard
Common
inline fun String.trimEnd(predicate: (Char) -> Boolean): String

Returns a string having trailing characters matching the predicate removed.

fun String.trimEnd(vararg chars: Char): String

Returns a string having trailing characters from the chars array removed.

inline fun String.trimEnd(): String

Returns a string having trailing whitespace removed.

trimIndent
Link copied to clipboard
Common
fun String.trimIndent(): String

Detects a common minimal indent of all the input lines, removes it from every line and also removes the first and the last lines if they are blank (notice difference blank vs empty).

trimMargin
Link copied to clipboard
Common
fun String.trimMargin(marginPrefix: String = "|"): String

Trims leading whitespace characters followed by marginPrefix from every line of a source string and removes the first and the last lines if they are blank (notice difference blank vs empty).

trimStart
Link copied to clipboard
Common
inline fun String.trimStart(predicate: (Char) -> Boolean): String

Returns a string having leading characters matching the predicate removed.

fun String.trimStart(vararg chars: Char): String

Returns a string having leading characters from the chars array removed.

inline fun String.trimStart(): String

Returns a string having leading whitespace removed.

uppercase
Link copied to clipboard
inline fun String.uppercase(locale: Locale): String

Returns a copy of this string converted to upper case using the rules of the specified locale.

fun String.uppercase(): String
inline fun String.uppercase(): String
inline fun String.uppercase(): String
fun String.uppercase(): String

Returns a copy of this string converted to upper case using Unicode mapping rules of the invariant locale.

utf16
Link copied to clipboard
Native
val String.utf16: CValues<UShortVar>
utf32
Link copied to clipboard
Native
val String.utf32: CValues<IntVar>
utf8
Link copied to clipboard
Native
val String.utf8: CValues<ByteVar>
wcstr
Link copied to clipboard
Native
val String.wcstr: CValues<UShortVar>